package com.example.xmldemo.uitl;

import java.util.Base64;

/**
 * @author liwq
 * @description
 * @date 2021/11/17 15:27
 */
public class Base64Util {

    public static String base64(String str) {
        byte[] bytes = str.getBytes();

        // Base64 加密
        String encoded = Base64.getEncoder().encodeToString(bytes);
        System.out.println("Base 64 加密后：" + encoded);

        // Base64 解密
        byte[] decoded = Base64.getDecoder().decode(encoded);

        String decodeStr = new String(decoded);
        System.out.println("Base 64 解密后：" + decodeStr);
        return decodeStr;

    }

    public static void main(String[] args) {
        String xml ="500102203109237615";
        xml = base64(xml);
        System.out.println(xml);
    }
}
